package org.ccams.dao;

import java.util.List;

import org.ccams.domain.TpMovbackD;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

public class TpMovbackDDAO extends SqlMapClientDaoSupport{
	/**
	 * 通过num取得调拨明细
	 * @param num
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public  List<TpMovbackD> getTpmovbackdByNum(Long num){		
		return getSqlMapClientTemplate().queryForList("tp_movback_d.getTpmovbackdByNum",num);
	}
	/**
	 * 插入调拨明细
	 * @param tmd
	 * @return
	 */
	public Integer insertTpmovbackd(TpMovbackD tmd){
		return getSqlMapClientTemplate().update("tp_movback_d.insertTpmovbackd",tmd);
	}
	/**
	 * 更新调拨明细
	 * @param tmd
	 * @return
	 */
	public int updateTpmovbackd(TpMovbackD tmd){
		return getSqlMapClientTemplate().update("tp_movback_d.updateTpmovbackd",tmd);
	}
	
	/**
	 * 取得最新插入的数据行的ord
	 * @return
	 */
	public Integer getNewOrd(Long num){
		try{
			return (Integer)getSqlMapClientTemplate().queryForObject("tp_movback_d.getNewOrd",num)+1;
		}catch(NullPointerException e){
			e.printStackTrace();
			return 0;
		}
	}
	
	/**
	 * 删除数据
	 * @param tmd
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public int deleteTpmovbackd(TpMovbackD tmd){
		return getSqlMapClientTemplate().delete("tp_movback_d.deleteTpmovbackd",tmd);
	}
	/**
	 * 更新审核
	 * @param tmd
	 * @return
	 */
	public int updateCommit(TpMovbackD tmd){
		return getSqlMapClientTemplate().update("tp_movback_d.updateCommit",tmd);
	}
	/**
	 * 验收入库
	 * @param tmd
	 * @return
	 */
	public int updateInspection(TpMovbackD tmd){
		return getSqlMapClientTemplate().update("tp_movback_d.updateInspection",tmd);
	}
}
